﻿@section styles{
    <style>
        .param-list {
            display: flex;
            justify-content: space-between;
        }
    </style>

}
<div class="content-wrapper">
    <section class="content-header">
        <h1>
            基础资料
            <small>区域站点分布</small>
        </h1>
        <ol class="breadcrumb">
            <li><a href="#"><i class="fa fa-dashboard"></i> 首页</a></li>
            <li><a href="#">基础资料</a></li>
            <li class="active">区域站点分布</li>
        </ol>
    </section>
    <section class="content">
        <div class="row">
            <div class="col-md-12">
                <div class="box">
                    <div class="box-body">
                        <input type="hidden" ref="ClientId" id="ClientId" value="@ViewBag.ClientId" />
                        <div style="padding:5px">
                            <div class="pull-right" style="padding:5px">
                                <a class="btn btn-primary" href="/DeviceData/Index"><i class="fa fa-undo"></i>返回</a>
                            </div>
                        </div>

                        <table id="bootstraptable" class="table table-bordered text-nowrap table-hover"></table>
                    </div>
                </div>
            </div>
        </div>
    </section>
</div>
@section scripts{
    <script type="text/javascript">


        var app = new Vue({
            el: '#app',
            data: {
                ClientId: ''
            },
            mounted: function () {
                var _self = this;
                _self.$nextTick(function () {
                    //显示active
                    _self.$refs.DeviceData.parentNode.parentNode.classList.add("active");
                    _self.$refs.DeviceData.classList.add("active");

                    setTimeout(function () {
                        _self.loadL();
                        setDataCardView("#bootstraptable");
                        //$("div[class='pull-right search']")[0].children[0].setAttribute("placeholder", "设备名称");
                    }, 500);
                });
            },
            methods: {
                loadL: function () {
                    _self = this;

                    var obj = [{
                        field: 'ClientId',
                        title: 'ClientId',
                        visible: false
                    }, {
                        field: 'DeviceId',
                        title: 'DeviceId',
                        visible: false
                    }, {
                        field: 'DeviceName',
                        title: '设备名称',
                        align: 'center',
                        valign: 'middle',
                        sortable: true,
                        formatter: function (value, row, index) {
                            var res = "";
                            res = "<a href='/DeviceDataHistory/Index?ClientId=" + row.ClientId + "&DeviceId=" + row.DeviceId + "'>" + row.ClientArea + " / " + row.ClientName + " / " + row.DeviceName + "</a>"
                            return res;
                        }
                    }, {
                        field: 'LastTime',
                        align: 'center',
                        title: '监测时间',
                        valign: 'middle',
                        sortable: true,
                        formatter: function (value, row, index) {
                            return _self.jsonDateFormat(value);
                        }
                    }, {
                        field: 'ParameterStatus',
                        align: 'center',
                        title: '状态',
                        sortable: true,
                        valign: 'middle',
                        formatter: function (value, row, index) {
                            var status = "";
                            if (row.ParameterStatus1 == 0 && row.ParameterStatus2 == 0 && row.ParameterStatus3 == 0
                                && row.ParameterStatus4 == 0) {
                                status = "label-success";
                            }
                            else if (row.ParameterStatus1 == 2 || row.ParameterStatus2 == 2 || row.ParameterStatus3 == 2
                                || row.ParameterStatus4 == 2) {
                                status = "label-danger";
                            }
                            else {
                                status = "label-warning";
                            }
                            status = "label-success";
                            if (status == "label-success") {
                                status = '<span class="label ' + status + '">正常</span>'
                                return status;
                            }
                            else if (status == "label-danger") {
                                status = '<span class="label ' + status + '">报警</span>'
                                return status;
                            }
                            else {
                                status = '<span class="label ' + status + '">故障</span>'
                                return status;
                            }

                        }
                    }, {
                        field: 'ParameterName',
                        align: 'left',
                        valign: 'middle',
                        title: '监测参数',
                        width: 100,
                        formatter: function (value, row, index) {
                            var BatteryV = "";
                            var WindV = "";
                            var WindI = "";
                            var WindP = "";

                            var WindR = "";
                            var PVV = "";
                            var PVI = "";
                            var PVP = "";

                            var WindDailyPower = "";
                            var WindTotalPower = "";
                            var PVDailyPower = "";
                            var PVTotalPower = "";

                            var DailyTotalPower = "";
                            var TotalPower = "";
                            var DailyUsePower = "";
                            var TotalUsePower = "";

                            var FloatV = "";
                            var MachineCommunicationH = "";
                            var MachineCommunicationL = "";
                            var ImageUrl = "";

                            var AllClose = "";
                            var Pump1Local = "";
                            var Pump2Local = "";
                            var Pump1Remote = "";

                            var Pump2Remote = "";
                            var Pump1Alarm = "";
                            var Pump2Alarm = "";
                            var Pump1Run = "";

                            var Pump2Run = "";
                            var MotorUp = "";
                            var MotorDown = "";
                            var WaterLevel = "";

                            var CH4 = "";
                            var Temperature = "";
                            var Humidity = "";


                            var result =
                                "<div class='param-list'>" +
                                '蓄电池电压:<span class="label label-success">' + row.BatteryV + 'V;</span>&emsp;' +
                                '风机电压:<span class="label label-success">' + row.WindV + 'V;</span>&emsp;' +
                                '风机电流:<span class="label label-success">' + row.WindI + 'A;</span>&emsp;' +
                                '风机功率:<span class="label label-success">' + row.WindP + 'W;</span>&emsp;' +
                                "</div>" +
                                "<hr/>" +
                                "<div class='param-list'>" +
                                '风机转速:<span class="label label-success">' + row.WindR + 'r/s;</span>&emsp;' +
                                '光伏电压:<span class="label label-success">' + row.PVV + 'V;</span>&emsp;' +
                                '光伏电流:<span class="label label-success">' + row.PVI + 'A;</span>&emsp;' +
                                '光伏功率:<span class="label label-success">' + row.PVP + 'W;</span>&emsp;' +
                                "</div>" +
                                "<hr/>" +
                                "<div class='param-list'>" +
                                '风机日发电量:<span class="label label-success">' + row.WindDailyPower + 'KWH;</span>&emsp;' +
                                '风机总发电量:<span class="label label-success">' + row.WindTotalPower + 'KWH;</span>&emsp;' +
                                '光伏日发电量:<span class="label label-success">' + row.PVDailyPower + 'KWH;</span>&emsp;' +
                                '光伏总发电量:<span class="label label-success">' + row.PVTotalPower + 'KWH;</span>&emsp;' +
                                "</div>" +
                                "<hr/>" +
                                "<div class='param-list'>" +
                                '日总发电量:<span class="label label-success">' + row.DailyTotalPower + 'KWH;</span>&emsp;' +
                                '总发电量:<span class="label label-success">' + row.TotalPower + 'KWH;</span>&emsp;' +
                                '日用电量:<span class="label label-success">' + row.DailyUsePower + 'KWH;</span>&emsp;' +
                                '总用电量:<span class="label label-success">' + row.TotalUsePower + 'KWH;</span>&emsp;' +
                                "</div>" +
                                "<hr/>" +
                                "<div class='param-list'>" +
                                '设备唯一通信ID高位:<span class="label label-success">' + row.MachineCommunicationH + ';</span>&emsp;' +
                                '设备唯一通信ID低位:<span class="label label-success">' + row.MachineCommunicationL + ';</span>&emsp;' +
                                '摄像头图像:<span class="label label-success">' + row.ImageUrl + ';</span>&emsp;' +
                                "</div>" +
                                "<hr/>" +
                                "<div class='param-list'>" +
                                '整体关机:<span class="label label-success">' + row.AllClose + ';</span>&emsp;' +
                                '泵1本地:<span class="label label-success">' + row.Pump1Local + ';</span>&emsp;' +
                                '泵2本地:<span class="label label-success">' + row.Pump2Local + ';</span>&emsp;' +
                                '泵1远程:<span class="label label-success">' + row.Pump1Remote + ';</span>&emsp;' +
                                "</div>" +
                                "<hr/>" +
                                "<div class='param-list'>" +
                                '泵2远程:<span class="label label-success">' + row.Pump2Remote + ';</span>&emsp;' +
                                '泵1故障:<span class="label label-success">' + row.Pump1Alarm + ';</span>&emsp;' +
                                '泵2故障:<span class="label label-success">' + row.Pump2Alarm + ';</span>&emsp;' +
                                '泵1运行:<span class="label label-success">' + row.Pump1Run + ';</span>&emsp;' +
                                "</div>" +
                                "<hr/>" +
                                "<div class='param-list'>" +
                                '泵2运行:<span class="label label-success">' + row.Pump2Run + ';</span>&emsp;' +
                                '支架电机上升:<span class="label label-success">' + row.MotorUp + ';</span>&emsp;' +
                                '支架电机下降:<span class="label label-success">' + row.MotorDown + ';</span>&emsp;' +
                                '液位:<span class="label label-success">' + row.WaterLevel + 'm;</span>&emsp;' +
                                "</div>" +
                                "<hr/>" +
                                "<div class='param-list'>" +
                                '甲烷浓度:<span class="label label-success">' + row.CH4 + ';</span>&emsp;' +
                                '温度:<span class="label label-success">' + row.Temperature + '℃;</span>&emsp;' +
                                '湿度:<span class="label label-success">' + row.Humidity + '%RH;</span>&emsp;' +
                                "</div>";
                            return result;
                        }
                    }, {
                        field: 'ParameterValue5',
                        align: 'center',
                        title: '摄像头截图',
                        valign: 'middle',
                        sortable: true,
                        formatter: function (value, row, index) {
                            return "<iframe src='https://open.ys7.com/ezopen/h5/iframe?url=ezopen://open.ys7.com/D73382282/1.live&autoplay=1&accessToken=at.5uted0ot9256yzty4wsc67ob8prddxza-3nq28lnq70-01nahad-bqn53zo0u' width='400' height='300' allowfullscreen></iframe>";
                        }
                    }];
                    _self.ClientId = _self.$refs.ClientId.value;
                    yui.tableHead("bootstraptable", "/DeviceData/MachineDetailsList?ClientId=" + _self.ClientId + "", obj, "POST", "ClientId");
                },
                playVideo() {

                }
            }
        });

    </script>
}